package InetAddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressDemo01 {
    public static void main(String[] args) throws Exception {
        //获取本机地址对象
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost);

        //获取域名ip对象
        InetAddress inetAddress = InetAddress.getByName("www.bilibili.com");
        System.out.println(inetAddress.getHostName());
        System.out.println(inetAddress.getHostAddress());
        //获取公网IP对象
        InetAddress inetAddress2 = InetAddress.getByName("112.80.248.76");
        System.out.println(inetAddress2.isReachable(5000));
    }
}
